/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kurvykurvy.ui.filter;

import java.io.File;
import java.io.FileFilter;

/**
 *
 * @author HY
 */
public class JPEGFileFilter
    extends javax.swing.filechooser.FileFilter
    implements FileFilter
{

    @Override
    public boolean accept( File f )
    {
        boolean result = false;
        if( f != null )
        {
            if( f.isFile() )
            {
                int extensionIndex = f.getName().lastIndexOf( '.' ) + 1;
                if( extensionIndex > 0 && extensionIndex < f.getName().length() )
                {
                    String extension = f.getName().substring( extensionIndex );
                    if( "JPG".equalsIgnoreCase( extension ) || "JPEG".equalsIgnoreCase( extension ) )
                    {
                        result = true;
                    }
                }                    
            }
            else
            {
                result = true;
            }
        }
        return true;
    }

    @Override
    public String getDescription()
    {
        return "JPG, JPEG Files";
    }
}
